package cn.chengpengper.nacos.client.naming;

import cn.chengpengper.nacos.api.common.Constants;
import cn.chengpengper.nacos.api.naming.NamingServer;
import cn.chengpengper.nacos.api.naming.pojo.Instance;
import cn.chengpengper.nacos.client.properties.NacosClientProperties;

import java.util.Properties;


public class NacosNamingService implements NamingServer {

    private NacosClientProperties nacosClientProperties;

    public NacosNamingService(Properties properties) {
        nacosClientProperties = NacosClientProperties.PROTOTYPE.derive(properties);
    }

    @Override
    public void registerInstance(String serviceName, String ip, int port, String clusterName) {
        registerInstance(serviceName, Constants.DEFAULT_GROUP, ip, port, clusterName);
    }

    @Override
    public void registerInstance(String serviceName, String groupName, String ip, int port, String clusterName) {
        // 创建服务实例对象
        Instance instance = new Instance();
        instance.setIp(ip);
        instance.setPort(port);
        instance.setWeight(1.0);
        instance.setClusterName(clusterName);
        registerInstance(serviceName, groupName, instance);
    }

    @Override
    public void registerInstance(String serviceName, String groupName, Instance instance) {
        //TODO 注册服务实例
    }
}
